<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Css变量加载不同大小图片</title>
    <style>
        :root {
            --bg-image: url(./vite.svg);
        }

        @media screen and (max-width: 600px) {
            :root {
                --bg-image: url(./vue-mastery-logo.png);
            }
        }

        .bg {
            width: 500px;
            height: 500px;
            background: var(--bg-image) no-repeat;
            background-size: 100% 100%;
        }
    </style>
</head>

<body>
    <div class="bg"></div>
</body>

</html>